//
//  LGFScreenLabel.swift
//  Auscultation
//
//  Created by 来 on 2021/1/25.
//

import UIKit

class LGFScreenLabel: UILabel {
    
    static var isShow: Bool = false
    
    class func show(_ text: String) {
        isShow = true
        let slabel = LGFScreenLabel.init()
        slabel.textAlignment = .center
        slabel.backgroundColor = UIColor.black.withAlphaComponent(0.4)
        slabel.textColor = UIColor.white
        slabel.font = UIFont.systemFont(ofSize: 20)
        slabel.numberOfLines = 0
        slabel.isUserInteractionEnabled = true
        let sv = UIApplication.shared.keyWindow?.rootViewController?.view
        slabel.frame = sv?.bounds ?? .zero
        sv?.addSubview(slabel)
        slabel.text = text
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        if touches.first?.view == self {
            LGFScreenLabel.isShow = false
            removeFromSuperview()
        }
    }
    
}
